<template>
  <q-dialog
    v-model="open"
    transition-show="rotate"
    transition-hide="rotate"
    content-class="center-dialog"
    content-style="max-width: 100vw; max-height: 100vh;"
  >
    <q-card class="box" style="margin-top: 350px">
      <q-card-section class="row items-center q-mt-md">
        <q-space />
        <q-btn icon="clear" flat round dense v-close-popup style="color: #fff" />
      </q-card-section>
      <div class="taskInfo">
        <div class="info">
          <span class="name">材料号</span>
          <span class="val">{{ orderInfo.matNo }}</span>
        </div>
        <div class="info">
          <span>起吊位</span>
          <span>{{ orderInfo.frPos }}</span>
        </div>
        <div class="info">
          <span>卸下位</span>
          <span>{{ orderInfo.toPos }}</span>
        </div>
        <div class="info">
          <span>材料状态</span>
          <span>{{ orderInfo.matStatus }}</span>
        </div>
        <div class="info">
          <span>下道机组</span>
          <span>{{ orderInfo.nextUnitNo }}</span>
        </div>
        <div class="info">
          <span>指令状态</span>
          <span>{{ orderInfo.orderStatus }}</span>
        </div>
        <div class="info">
          <span>指令类型</span>
          <span>{{ orderInfo.orderType }}</span>
        </div>
        <div class="info">
          <span>指令号</span>
          <span>{{ orderInfo.orderNo }}</span>
        </div>
        <div class="info">
          <span>宽度</span>
          <span>{{ orderInfo.width }}</span>
        </div>
        <div class="info">
          <span>卷径</span>
          <span>{{ '???' }}</span>
        </div>
      </div>
    </q-card>
  </q-dialog>
</template>

<script lang="ts">
import { defineComponent, ref } from 'vue';
import { useEmitter } from 'src/emitter';
import { getMatInfo } from '../api';

export default defineComponent({
  name: 'terminal-crane-task-detail',

  setup() {
    const open = ref(false);
    const orderInfo = ref<Record<string, any>>({});

    useEmitter('inform', async payload => {
      if (payload.name !== 'terminal-task-detail') {
        return;
      }
      open.value = payload.value.isOpen;
      const { data } = await getMatInfo(payload.value.orderNo);
      orderInfo.value = data;
    });

    return {
      open,
      orderInfo,
    };
  },
});
</script>

<style lang="scss" scoped>
.center-dialog {
  display: flex;
  justify-content: center;
  align-items: flex-start; /* 改为顶部对齐 */
  width: 100%;
  height: 100%;
  max-width: 1024px;
  max-height: 768px;
  margin: 0 auto;
  padding-top: 500px; /* 添加顶部外边距 */
}

.box {
  position: relative;
  width: 500px;
  height: 540px;
  background-color: transparent;
  background-image: url('src/assets/terminal/task_detail_bg.png');
  background-size: 100% 100%;
}

.taskInfo {
  position: absolute;
  width: 420px;
  height: 440px;
  top: 80px;
  left: 0;
  right: 0;
  margin: auto;
  text-align: left;
  color: #fff;
  font-size: 14px;
  font-weight: bold;
  .info {
    display: flex;
    width: 100%;
    height: 40px;
    line-height: 40px;
    justify-content: space-between;
    span:nth-child(1) {
      width: 250px;
      height: 40px;
      padding-left: 16px;
    }
    span:nth-child(2) {
      width: 150px;
      height: 40px;
      padding-left: 16px;
    }
  }
}

.taskInfo .info:nth-child(odd) span {
  background-image: url('src/assets/terminal/task_title_bg.png');
  background-size: 100% 100%;
}

/*自定义滚动条样式*/
.taskInfo ::-webkit-scrollbar {
  /*滚动条整体样式*/
  width: 10px; /*高宽分别对应横竖滚动条的尺寸*/
  height: 10px;
}

.taskInfo ::-webkit-scrollbar-thumb {
  /*滚动条里面小方块*/
  border-radius: 10px;
  // -webkit-box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.2);
  background: rgb(153, 153, 153);
}

.taskInfo ::-webkit-scrollbar-track {
  /*滚动条里面轨道*/
  // -webkit-box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.2);
  border-radius: 10px;
  background: rgb(128, 128, 128);
}
</style>
